<%
layout("/layouts/platform.html"){
%>
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-primary navbar-btn" href="${base}/platform/sys/route" data-pjax><i class="ti-angle-left"></i> 返回</a>
    </div>
</header>

<div class="content-wrap">
    <div class="wrapper" style="min-height:500px;">
        <section class="panel panel-form">
            <form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
                  action="${base}/platform/sys/route/addDo" method="post">
                <div class="row mb10">
                    <div class="col-lg-12">
                        <div class="form-group">
                            <label for="url" class="col-sm-2 control-label">原始URL</label>
                            <div class="col-sm-8">
                            <input type="text" id="url" class="form-control" name="url" data-parsley-required="true" placeholder="原始路径">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="toUrl" class="col-sm-2 control-label">转发URL</label>
                            <div class="col-sm-8">
                                <input type="text" id="toUrl" class="form-control" name="toUrl" data-parsley-required="true" placeholder="转发路径">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="type" class="col-sm-2 control-label">转发类型</label>
                            <div class="col-sm-8">
                                <select id="type" name="type" class="form-control" >
                                    <option value="hide">隐性URL</option>
                                    <option value="show">显性URL</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="disabled" class="col-sm-2 control-label">是否禁用</label>
                            <div class="col-sm-8 switcha">
                                <div class="mr15">
                                    <input type="checkbox" id="disabled" name="disabled" class="js-switch-blue" >
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-3"></div>
                <div class="col-lg-6">
                    <div class="form-group text-center">
                        <label></label>

                        <div>
                            <button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
                        </div>
                    </div>
                </div>
            </form>
        </section>
    </div>
</div>
<script language="JavaScript">
    $(document).ready(function () {
        myForm.init();
        $('#addForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
                if($("#type").val()=="hide"&&$("#toUrl").val().indexOf("http")>-1){
                    Toast.error("隐性URL不可为外链");
                    return false;
                }
                form.find("button:submit").button("loading");
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    Toast.success(data.msg);
                    //刷新父级菜单
                    form.resetForm();
                } else {
                    Toast.error(data.msg);
                }
                form.find("button:submit").button("reset");
            }
        });
    });
</script>
<%}%>


